
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EBAS_STUDERENDE_FAG]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[EBAS_STUDERENDE_FAG]
GO

CREATE TABLE [dbo].[EBAS_STUDERENDE_FAG] (
	[GUID] [uniqueidentifier] ROWGUIDCOL NOT NULL ,
	[TID] [datetime] NULL ,
	[OMSKRIV] [int] NULL ,
	[AFSENDT] [datetime] NULL ,
	[MODTAGET] [datetime] NULL ,
	[RYKKER_1] [datetime] NULL ,
	[BEMAERKNING] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NULL ,
	[KARAKTER_GUID] [uniqueidentifier] NULL ,
	[STUDERENDE_GUID] [uniqueidentifier] NOT NULL ,
	[FAG_GUID] [uniqueidentifier] NOT NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[EBAS_STUDERENDE_FAG] WITH NOCHECK ADD 
	CONSTRAINT [DF_EBAS_STUDERENDE_FAG_OMSKRIV] DEFAULT (0) FOR [OMSKRIV],
	CONSTRAINT [PK_EBAS_STUDERENDE_FAG] PRIMARY KEY  CLUSTERED 
	(
		[GUID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[EBAS_STUDERENDE_FAG] ADD 
	CONSTRAINT [FK_EBAS_STUDERENDE_FAG_EBAS_KARAKTER] FOREIGN KEY 
	(
		[KARAKTER_GUID]
	) REFERENCES [dbo].[EBAS_KARAKTER] (
		[GUID]
	),
	CONSTRAINT [FK_EBAS_STUDERENDE_FAG_EBAS_STUDERENDE] FOREIGN KEY 
	(
		[STUDERENDE_GUID]
	) REFERENCES [dbo].[EBAS_STUDERENDE] (
		[GUID]
	)
GO
